package gui;

import java.awt.GridLayout;

import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class InputPanel extends JPanel{
	private static final long serialVersionUID = 1L;
	String[] yn = {"Yes", "No", "?"};
	JComboBox<String> comboEcol = new JComboBox<String>(yn);
	JComboBox<String> comboSalm = new JComboBox<String>(yn);
	JComboBox<String> comboShig = new JComboBox<String>(yn);
	JComboBox<String> comboCarbon_Monoxide = new JComboBox<String>(yn);
	JComboBox<String> comboLead = new JComboBox<String>(yn);
	JComboBox<String> comboNitrogen_Dioxide = new JComboBox<String>(yn);
	JComboBox<String> comboOzone = new JComboBox<String>(yn);
	JComboBox<String> comboParticulate_Matter = new JComboBox<String>(yn);
	JComboBox<String> comboSulfur_Dioxide = new JComboBox<String>(yn);
	JTextField testToxic_Chem = new JTextField();
	JTextField testprecipitationInches = new JTextField();
	public InputPanel(){
		JPanel row = new JPanel();
		row.setLayout(new GridLayout(13,2));
		add(row);
		row.add(new JLabel("Ecol"));
		row.add(comboEcol);
		row.add(new JLabel("Salm"));
		row.add(comboSalm);
		row.add(new JLabel("Shig"));
		row.add(comboShig);
		row.add(new JLabel("Carbon_Monoxide"));
		row.add(comboCarbon_Monoxide);
		row.add(new JLabel("Lead"));
		row.add(comboLead);
		row.add(new JLabel("Nitrogen_Dioxide"));
		row.add(comboNitrogen_Dioxide);
		row.add(new JLabel("Ozone"));
		row.add(comboOzone);
		row.add(new JLabel("Particulate_Matter"));
		row.add(comboParticulate_Matter);
		row.add(new JLabel("Sulfur_Dioxide"));
		row.add(comboSulfur_Dioxide);
		row.add(new JLabel("Toxic_Chem"));
		row.add(testToxic_Chem);
		row.add(new JLabel("precipitationInches"));
		row.add(testprecipitationInches);
	}
	public boolean valid(){
//		if(comboEcol.getSelectedIndex()==0)return false;
//		if(comboSalm.getSelectedIndex()==0)return false;
//		if(comboShig.getSelectedIndex()==0)return false;
//		if(comboCarbon_Monoxide.getSelectedIndex()==0)return false;
//		if(comboLead.getSelectedIndex()==0)return false;
//		if(comboNitrogen_Dioxide.getSelectedIndex()==0)return false;
//		if(comboOzone.getSelectedIndex()==0)return false;
//		if(comboParticulate_Matter.getSelectedIndex()==0)return false;
//		if(comboSulfur_Dioxide.getSelectedIndex()==0)return false;
		return true;
	}
	@Override
	public String toString(){
		return comboEcol.getSelectedItem().toString().substring(0, 1) + "," + comboSalm.getSelectedItem().toString().substring(0, 1) + "," + comboShig.getSelectedItem().toString().substring(0, 1) + "," +
		comboCarbon_Monoxide.getSelectedItem().toString().substring(0, 1) + "," + comboLead.getSelectedItem().toString().substring(0, 1) + "," + comboNitrogen_Dioxide.getSelectedItem().toString().substring(0, 1) + "," +
		comboOzone.getSelectedItem().toString().substring(0, 1) + "," + comboParticulate_Matter.getSelectedItem().toString().substring(0, 1) + "," + comboSulfur_Dioxide.getSelectedItem().toString().substring(0, 1) + "," +
		(testToxic_Chem.getText().isEmpty() ? "?":testToxic_Chem.getText()) + "," + (testprecipitationInches.getText().isEmpty() ? "?" :testprecipitationInches.getText());
	}
}
